#include<stdio.h>
int main()
{
	int year,month,day,T;
	scanf("%d %d %d",&year,&month,&day);
	if ((year%4==0 && year%100!=0)||(year%400==0))
	T=31+29;
	else
	T=31+28;
	switch(month)
	{
		case 1:printf("%d\n",day%7);
		break;
		case 2:printf("%d\n",(day+31)%7);
		break;
		case 3:printf("%d\n",(day+T)%7);
		break;
		case 4:printf("%d\n",(day+T+31)%7);
		break;
		case 5:printf("%d\n",(day+T+31+30)%7);
		break;
		case 6:printf("%d\n",(day+T+31*2+30)%7);
		break;
		case 7:printf("%d\n",(day+T+31*2+30*2)%7);
		break;
		case 8:printf("%d\n",(day+T+31*3+30*2)%7);
		break;
		case 9:printf("%d\n",(day+T+31*4+30*2)%7);
		break;
		case 10:printf("%d\n",(day+T+31*4+30*3)%7);
		break;
		case 11:printf("%d\n",(day+T+31*5+30*3)%7);
		break;
		case 12:printf("%d\n",(day+T+31*5+30*3)%7);
		break;
	}
	return 0;
}
